package year2022.month456789;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;

import java.time.LocalDateTime;
import java.time.temporal.TemporalAdjusters;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;

public class ListTest {

    public static void main(String[] args){
        List<Integer> list1 = new ArrayList<Integer>(){{
            add(1);
            add(2);
            add(3);
            add(4);
            add(5);
            add(6);
        }};

        List<Integer> list2 = new ArrayList<Integer>(){{
            add(1);
            add(3);
            add(5);
            add(7);
            add(9);
        }};

        Collection<Integer> intersection = CollUtil.intersection(list1, list2);

        intersection.forEach(System.out::println);

        LocalDateTime yearMonth = LocalDateTime.now();

        LocalDateTime firstDay = null;
        LocalDateTime lastDay = null;
        if (ObjectUtil.isNotNull(yearMonth)) {
            firstDay = yearMonth.with(TemporalAdjusters.firstDayOfMonth()).withHour(0).withMinute(0).withSecond(0);
            lastDay = yearMonth.with(TemporalAdjusters.lastDayOfMonth()).withHour(23).withMinute(59).withSecond(59);
        }

        System.out.println(firstDay);
        System.out.println(lastDay);
    }

}
